package com.bringway.p2p.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.bringway.framework.controller.JsonController;
import com.bringway.framework.util.RequestUtils;
import com.bringway.p2p.service.ModSjhmService;

import net.sf.json.JSONObject;
/**  
 * @类名 ModSjhmController  
 * @功能 TODO  修改手机号码记录 查询
 * @作者 js 
 * @日期 2016年11月25日 下午2:49:40  
 *    
 */
@Controller
@RequestMapping("/modSjhm")
public class ModSjhmController extends JsonController{
	@Autowired
	private ModSjhmService modSjhmService;
	/**
	 * @作者 js  
	 * @方法名 queryOpinfoList  
	 * @功能 TODO 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/queryModSjhmListAll")
	public ModelAndView queryModSjhmListAll(HttpServletRequest request,HttpServletResponse response) throws Exception{
		JSONObject params = new JSONObject();
		JSONObject result = new JSONObject();
		Integer page = RequestUtils.getIntParameter(request, "page");//新版本,传参
		Integer start = RequestUtils.getIntParameter(request, "start");
		Integer limit = RequestUtils.getIntParameter(request, "limit");
		if (null!=page) {//新版本,传参
			start=(page-1)*limit;
		}
		String startDate = RequestUtils.getStringParameter(request, "startDate");
		String endDate = RequestUtils.getStringParameter(request, "endDate");
		String yhm = RequestUtils.getStringParameter(request, "yhm");
		String sjhmy = RequestUtils.getStringParameter(request, "sjhmy");
		String sjhmx = RequestUtils.getStringParameter(request, "sjhmx");
		params.put("start", start);
		params.put("limit", limit);
		params.put("startDate", startDate);
		params.put("endDate", endDate);
		params.put("yhm", yhm);
		params.put("sjhmy", sjhmy);
		params.put("sjhmx", sjhmx);
		List<Map<String, Object>> list = modSjhmService.queryModSjhmListAll(params);
		int count = modSjhmService.getModSjhmCount(params);
		result.put("data", list);
		result.put("total", count);
		if (null!=page) {//新版本,传参
			int totalPage=count%limit==0?count/limit:count/limit+1;
			result.put("totalPage", totalPage);
			
		}
		serialize(request, response, result);
		return null;
	}
}


